package com.iot.web.controller.device;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iot.common.annotation.Log;
import com.iot.common.core.controller.BaseController;
import com.iot.common.core.domain.AjaxResult;
import com.iot.common.enums.BusinessType;
import com.iot.device.domain.PressureSensorEvent;
import com.iot.device.service.IPressureSensorEventService;
import com.iot.common.utils.poi.ExcelUtil;
import com.iot.common.core.page.TableDataInfo;

/**
 * 压力传感器事件Controller
 * 
 * @author iot
 * @date 2023-06-30
 */
@RestController
@RequestMapping("/device/pressureSensorEvent")
public class PressureSensorEventController extends BaseController
{
    @Autowired
    private IPressureSensorEventService pressureSensorEventService;

    /**
     * 查询压力传感器事件列表
     */
    @PreAuthorize("@ss.hasPermi('device:pressureSensorEvent:list')")
    @GetMapping("/list")
    public TableDataInfo list(PressureSensorEvent pressureSensorEvent)
    {
        startPage();
        List<PressureSensorEvent> list = pressureSensorEventService.selectPressureSensorEventList(pressureSensorEvent);
        return getDataTable(list);
    }

    /**
     * 导出压力传感器事件列表
     */
    @PreAuthorize("@ss.hasPermi('device:pressureSensorEvent:export')")
    @Log(title = "压力传感器事件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PressureSensorEvent pressureSensorEvent)
    {
        List<PressureSensorEvent> list = pressureSensorEventService.selectPressureSensorEventList(pressureSensorEvent);
        ExcelUtil<PressureSensorEvent> util = new ExcelUtil<PressureSensorEvent>(PressureSensorEvent.class);
        util.exportExcel(response, list, "压力传感器事件数据");
    }

    /**
     * 获取压力传感器事件详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:pressureSensorEvent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pressureSensorEventService.selectPressureSensorEventById(id));
    }

    /**
     * 新增压力传感器事件
     */
    @PreAuthorize("@ss.hasPermi('device:pressureSensorEvent:add')")
    @Log(title = "压力传感器事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PressureSensorEvent pressureSensorEvent)
    {
        return toAjax(pressureSensorEventService.insertPressureSensorEvent(pressureSensorEvent));
    }

    /**
     * 修改压力传感器事件
     */
    @PreAuthorize("@ss.hasPermi('device:pressureSensorEvent:edit')")
    @Log(title = "压力传感器事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PressureSensorEvent pressureSensorEvent)
    {
        return toAjax(pressureSensorEventService.updatePressureSensorEvent(pressureSensorEvent));
    }

    /**
     * 删除压力传感器事件
     */
    @PreAuthorize("@ss.hasPermi('device:pressureSensorEvent:remove')")
    @Log(title = "压力传感器事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pressureSensorEventService.deletePressureSensorEventByIds(ids));
    }
}
